import { expect } from 'chai';
import parseQuery from '../src/parseQuery';

describe('parseQuery unit test', function() {
    it('should return empty object for empty arguments', function() {
        expect(parseQuery()).to.be.eql({});
    });

    it('should return valid object for normal url', function() {
        const url = 'example.com?hello=world&answer=42';
        const result = {
            hello: 'world',
            answer: '42',
        }

        expect(parseQuery(url)).to.be.eql(result);
    });

    it('should return valid object for normal url with hash', function() {
        const url = 'example.com?hello=world&answer=42#baz';
        const result = {
            hello: 'world',
            answer: '42',
        }

        expect(parseQuery(url)).to.be.eql(result);
    });

    it('should return valid object for normal url with only hash', function() {
        const url = 'example.com#baz';
        const result = {};

        expect(parseQuery(url)).to.be.eql(result);
    });
});